<?=$this->form ( $this->element->getName (), $this->element->getAttribs (), false ); ?>
<?php
    echo $this->renderElement ( $this->element->codtab );
    echo $this->renderElement ( $this->element->codboton );
    echo $this->renderElement ( $this->element->codboton2 );
    $sesionTabBoton = new Zend_Session_Namespace("TABBOTON");
    $sesionNormas = new Zend_Session_Namespace("NORMAS");
   
    $domConfig = Zend_Registry::get('domConfig'); //esto se crea en el bootstrap
	$array_instalaciones = $domConfig->INSTALACION_FISICA->toArray();
	$array_tenencia = $domConfig->TENENCIA->toArray();
	$array_puestos = $domConfig->PUESTOS_INSTALACION_FISICA->toArray();
	
	$elementos = array();
	foreach ($this->element as $value){
	    $elementos[$value->getName()] = $value;
	}
	
?>
<div align="center" width="100%">
  <table width="95%" class="iceDatTbl zebra" border=0>
    <tr>
      <td rowspan="3" align="center" valign="middle"><strong>USO DE ESPACIOS</strong></td>
      <td colspan="10"><div align="center"><strong>TENENCIA</strong></div></td>
    </tr>
    <tr>
      <?php foreach ($array_tenencia as $value):
          echo "<td colspan=\"2\"><div align=\"center\"><strong>{$value}</strong></div></td>";
       endforeach;?>
      <td colspan="2"><div align="center"><strong>Total</strong></div></td>
    </tr>
   <tr>
      <?php foreach ($array_tenencia as $value):
          echo "<td><div align=\"center\"><strong>CANTIDAD DE ESPACIOS</strong></div></td>";
          echo "<td><div align=\"center\"><strong>METROS&sup2;</strong></div></td>";
       endforeach;?>
      <td><div align="center"><strong>CANTIDAD DE ESPACIOS</strong></div></td>
      <td><div align="center"><strong>METROS&sup2;</strong></div></td>
    </tr>
    <?php
	foreach($array_instalaciones as $keyi =>$valuei){
	    echo "<tr><td><div align=\"left\">{$valuei}</div></td>";
	    foreach($array_tenencia as $keyt =>$valuet){
	       echo "<td><div align= \"center\">";
	       $elemento_cantidad = "cantidad_{$keyi}_{$keyt}";
		   echo $this->renderElement ( $elementos["cantidad_{$keyi}_{$keyt}"] );
		   echo $this->element->$elemento_cantidad->renderErrors ();
	       echo "</div></td>";
	       echo "<td><div align=\"center\">";
	       $elemento_area = "area_{$keyi}_{$keyt}";
		   echo $this->renderElement ( $elementos["area_{$keyi}_{$keyt}"] );
		   echo $this->element->$elemento_area->renderErrors ();
	       echo "</div></td>";
		}
	    echo "<td><div align= \"center\">";
		echo $this->renderElement ( $elementos["sumac_{$keyi}"] );
	    echo "</div></td>";
	    echo "<td><div align=\"center\">";
		echo $this->renderElement ( $elementos["sumaa_{$keyi}"] );
	    echo "</div></td>";
        echo "</tr>";
	}
     echo "<tr><td><div align=\"center\"><strong>TOTALES</strong></div></td>";
	 foreach($array_tenencia as $keyt =>$valuet){
	       echo "<td><div align= \"center\">";
		   echo $this->renderElement ( $elementos["sumae_{$keyt}"] );
	       echo "</div></td>";
	       echo "<td><div align=\"center\">";
		   echo $this->renderElement ( $elementos["sumam_{$keyt}"] );
	       echo "</div></td>";
		}
	echo "<td><div align= \"center\">";
	echo $this->renderElement ( $elementos["sumae"] );
	echo "</div></td>";
	echo "<td><div align=\"center\">";
	echo $this->renderElement ( $elementos["sumam"] );
	echo "</div></td>";
    echo "</tr>";

    echo "<tr><td colspan=11>&nbsp;</td></tr>";
    foreach($array_puestos as $keyi =>$valuei){
	    echo "<tr><td><div align=\"left\">{$valuei}</div></td>";
	    foreach($array_tenencia as $keyt =>$valuet){
	       echo "<td td colspan=\"2\"><div align= \"center\">";
		   echo $this->renderElement ( $elementos["cantidad_{$keyi}_{$keyt}"] );
		   $elemento_cantidad = "cantidad_{$keyi}_{$keyt}";
		   echo $this->element->$elemento_cantidad->renderErrors ();
	       echo "</div></td>";
//	       echo "<td><div align=\"center\">";
//		   echo $this->renderElement ( $elementos["area_{$keyi}_{$keyt}"] );
//	       echo "</div></td>";
		}
	    echo "<td colspan=\"2\"><div align= \"center\">";
		echo $this->renderElement ( $elementos["sumac_{$keyi}"] );
	    echo "</div></td>";
//	    echo "<td><div align=\"center\">";
//		echo $this->renderElement ( $elementos["sumaa_{$keyi}"] );
//	    echo "</div></td>";
        echo "</tr>";
	}
    
    echo "<tr><td><div align=\"center\"><strong>TOTALES</strong></div></td>";
	foreach($array_tenencia as $keyt =>$valuet){
	    echo "<td colspan=\"2\"><div align= \"center\">";
		echo $this->renderElement ( $elementos["sumape_{$keyt}"] );
	    echo "</div></td>";
//	    echo "<td><div align=\"center\">";
//		echo $this->renderElement ( $elementos["sumapm_{$keyt}"] );
//	    echo "</div></td>";
	}
	echo "<td colspan=\"2\"><div align= \"center\">";
	echo $this->renderElement ( $elementos["sumape"] );
	echo "</div></td>";
//	echo "<td><div align=\"center\">";
//	echo $this->renderElement ( $elementos["sumapm"] );
//	echo "</div></td>";
    echo "</tr>";
	
//    echo "<tr><td colspan=11>&nbsp;</td></tr>";
//    echo "<tr><td><div align=\"left\">Promedio de puestos por aula de clase</div></td>";
//	foreach($array_tenencia as $keyt =>$valuet){
//	    echo "<td><div align= \"center\">";
//		echo $this->renderElement ( $elementos["cantidad_50_{$keyt}"] );
//	    echo "</div></td>";
//	    echo "<td><div align=\"center\">";
//		echo $this->renderElement ( $elementos["area_50_{$keyt}"] );
//	    echo "</div></td>";
//	}
//	echo "<td><div align= \"center\">";
//	echo $this->renderElement ( $elementos["sumac_50"] );
//	echo "</div></td>";
//	echo "<td><div align=\"center\">";
//	echo $this->renderElement ( $elementos["sumaa_50"] );
//	echo "</div></td>";
//    echo "</tr>";
    $promedio = 0;
    if ($elementos["sumape"]->getValue()>0 && ($elementos["sumac_1"]->getValue()+$elementos["sumac_2"]->getValue())>0){
//        $promedio = round($elementos["sumape"]->getValue()/($elementos["sumac_1"]->getValue()+$elementos["sumac_2"]->getValue()));
        $promedio = round($elementos["sumac_30"]->getValue()/($elementos["sumac_1"]->getValue()),2);
    }

    echo "<tr><td colspan=11>&nbsp;</td></tr>";
    echo "<tr><td colspan=11><div align= \"center\">";
    echo "  <strong><a href='#' alt='Total puestos de las aulas de clase/Suma de aulas de clase' title='Total puestos de las aulas de clase/Suma de aulas de clase'>PROMEDIO DE PUESTOS POR AULAS DE CLASE= {$promedio}</a></strong>";
    echo "</td></tr>";

     
	if (! $this->element->isStatic ()) :
	?>
    <tr>
		<td colspan="12" class="iceDatTblRow2"><div align="center">
        <?php
		echo $this->renderElement ( $this->element->btnSubmit );
		?>
        </div></td>
	</tr>
	<?php
	endif;
	?>
  </table>
</div>
</form>